package 第八章;

import java.util.*;
public class test6 {
    public static void main(String[] args) {
        String s = "数学87分，物理76分，英语96分";
        Scanner scanner = new Scanner(s);
        scanner.useDelimiter("[^0123456789]+");
        double sum = 0;
        int count=0;
        while (scanner.hasNext()) {
            try {
                double score = scanner.nextInt();
                count++;
                sum = sum + score;
                System.out.println(score);
            } catch (Exception e) {
                String t = scanner.next();
            }
        }
        System.out.println("sum=" + sum+"分");
        System.out.println("avg=" + sum / count+"分");

    }
}
